#include "thread.h"
#include "decodec.h"

using namespace std;

FileSource FileSources[] = {
    {1, 1920, 1080, "../res/Tennis1080p.h264", "../res/Tennis1080p.yuv", MPP_VIDEO_CodingAVC},
};

void *thread_exec(void *args){
    int ret = 0;

    decodec *ctx = new decodec();
    ret = ctx->init(args);
    if(ret){
        cout << "failed to init decodec ret " << ret << endl;
        delete ctx;
        ctx = NULL;
        return NULL;
    }
    
    ret = ctx->decode();
    if (ret < 0)
        cout << "codec decode exec failed" << endl;
    else
        cout << "codec decode exec success" << endl;
        
    ctx->deinit();
    delete ctx;

    return NULL;
}

void stop(int signo) {
    cout << "mpp_linux_demo exit";
    exit(0);
}

int main(int argc, char const *argv[])
{
    signal(SIGINT, stop);

    thread *tFirst = new thread(thread_exec, &FileSources[0], NULL);
    
    tFirst->init();

    tFirst->run();

    delete tFirst;
    return 0;
}
